package com.ljfirst.循环发令枪;

import java.util.concurrent.CyclicBarrier;

/**
 * @author liujun
 * @version 1.0
 * @date 2020/12/2
 * @author—Email liujunfirst@outlook.com
 * @blogURL https://blog.csdn.net/ljfirst
 * @description 循环发令枪
 * 能够重复使用的发令枪：CyclicBarrier
 */
public class demo {

    public static void main(String[] args) {
        int threadNum = 5;

        CyclicBarrier barrier = new CyclicBarrier(threadNum, new Runnable() {
            @Override
            public void run() {
                System.out.println(Thread.currentThread().getName() + " 完成最后任务");
            }
        });

        for (int i = 0; i < threadNum; i++) {
            new TaskThread(barrier).start();
        }
    }

}
